package com.itheima;

import com.itheima.pojo.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author zhangyan
 * @date 2020/8/19 20:27
 */
public class Test02 {
    public static void main(String[] args) {

        ApplicationContext context1 = new ClassPathXmlApplicationContext("applicationContext.xml");

        //1.根据类型获取对象 (xml配置文件中只能有唯一同类型的对象 否则报错)
        //User user = context1.getBean(User.class);
        //System.out.println("根据类型获取对象:" + user);

        //2.根据名字和类型获取对象
        User user01 = context1.getBean("user01",User.class);
        System.out.println("根据名字和类型获取对象:" + user01);

    }
}
